﻿using Abp.Application.Services;
using Abp.Application.Services.Dto;
using Abp.Domain.Repositories;
using Abp.ObjectMapping;
using OplugAbpProject.Transaction.Dto;
using System.Threading.Tasks;
using System.Linq;

namespace OplugAbpProject.Transaction
{
    public class MerchSaftyInfoAppService : AsyncCrudAppService<MerchSaftyInfo, MerchSaftyInfoDto, long, PagedResultRequestDto, CreateMerchSaftyInfoDto, UpdateMerchSaftyInfoDto>
    {
        private readonly IObjectMapper _objectMapper;

        public MerchSaftyInfoAppService(IRepository<MerchSaftyInfo, long> repository, IObjectMapper objectMapper) : base(repository)
        {
            _objectMapper = objectMapper;
        }

        public async Task<MerchSaftyInfoDto> GetByMerchId(int merchId)
        {
            var obj = (await Repository.GetAllListAsync(o=>o.MerchId== merchId)).FirstOrDefault();
            return ObjectMapper.Map<MerchSaftyInfoDto>(obj);
        }
    }
}
